package com.sky.controller.user;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.result.Result;
import com.sky.service.SetMealService;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userSeatMealController")
@RequestMapping("/user/setmeal")
@Slf4j
@Api(tags = "用户端-套餐接口")
public class SeatMealController {

    @Autowired
    private SetMealService setMealService;

    //Request URL: http://localhost:8080/user/setmeal/list?categoryId=13
    @GetMapping("/list")
    public Result<List<SetmealVO>> list(SetmealDTO setmealDTO) {
        List<SetmealVO> setmealVO = setMealService.list(setmealDTO);
        return Result.success(setmealVO);
    }

    //Request URL: http://localhost:8080/user/setmeal/dish/1
    @GetMapping("/dish/{setmealId}")
    public Result<List<DishItemVO>> dishesInSetmeal(@PathVariable Long setmealId){
        log.info("具体查看了套餐{}里面的菜",setmealId);
        List<DishItemVO> dishItemVO = setMealService.getDishesBySetmealId(setmealId);
        return Result.success(dishItemVO);

    }

}
